package com.example.pixelyear.sql

import android.content.Context
import android.database.Cursor
import android.database.sqlite.SQLiteDatabase

open class BaseSqlUtils(context: Context) {
    private val sql by lazy {
        Sql(context)
    }

    val write: SQLiteDatabase
        get() = getWriteDataBase()

    val read: SQLiteDatabase
        get() = getReadDataBase()

    private fun getWriteDataBase(): SQLiteDatabase {
        val writableDatabase = sql.writableDatabase
        writableDatabase.disableWriteAheadLogging()
        return writableDatabase
    }

    private fun getReadDataBase(): SQLiteDatabase {
        val writableDatabase = sql.writableDatabase
        writableDatabase.disableWriteAheadLogging()
        return writableDatabase
    }


    fun close() {
        write.close()
        read.close()
    }


}
